| Conditions | 1 |
| Paths | 1 |
| Total Lines | 166 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | describe('Abe', function() { |
||
| 2 | |||
| 3 | describe('operations', function() { |
||
| 4 | |||
| 5 | before(function(client, done) { |
||
| 6 | done(); |
||
| 7 | }); |
||
| 8 | |||
| 9 | after(function(client, done) { |
||
| 10 | client.end(function() { |
||
| 11 | done(); |
||
| 12 | }); |
||
| 13 | }); |
||
| 14 | |||
| 15 | afterEach(function(client, done) { |
||
| 16 | done(); |
||
| 17 | }); |
||
| 18 | |||
| 19 | beforeEach(function(client, done) { |
||
| 20 | done(); |
||
| 21 | }); |
||
| 22 | |||
| 23 | it('Create a single article', function(client) { |
||
| 24 | client |
||
| 25 | .url('http://localhost:3003/abe/editor') |
||
| 26 | .waitForElementVisible('body') |
||
| 27 | .assert.title('Abe') |
||
| 28 | .click('select[id="level-1"] option:nth-child(2)') |
||
| 29 | .click('select[name="selectTemplate"] option[value="single"]') |
||
| 30 | .waitForElementVisible('div[data-precontrib-templates=single]', 1000) |
||
| 31 | .setValue('div[data-precontrib-templates=single] > div > input', 'ftest') |
||
| 32 | .click('button[type="submit"]') |
||
| 33 | .waitForElementVisible('form[id="abeForm"]', 2000) |
||
| 34 | .assert.urlEquals("http://localhost:3003/abe/editor/articles/ftest.html", "Clicked URL Matches with URL of the New Window"); |
||
| 35 | }); |
||
| 36 | |||
| 37 | it('The created single article is found in the manager', function(client) { |
||
| 38 | client |
||
| 39 | .useXpath() |
||
| 40 | .url('http://localhost:3003/abe/editor') |
||
| 41 | .waitForElementVisible('//body') |
||
| 42 | .pause(1000) |
||
| 43 | .assert.containsText("//table[@id='navigation-list']/tbody/tr[1]/td[2]/a", "/articles/ftest.html"); |
||
| 44 | }); |
||
| 45 | |||
| 46 | it('The created single article is edited and updated with no change', function(client) { |
||
| 47 | client |
||
| 48 | .useXpath() |
||
| 49 | .url('http://localhost:3003/abe/editor/articles/ftest.html#slug') |
||
| 50 | .waitForElementVisible('//body') |
||
| 51 | .assert.title('Abe') |
||
| 52 | .click("//button[@class='btn btn-primary'][2]") |
||
| 53 | .pause(2000) |
||
| 54 | .assert.urlEquals("http://localhost:3003/abe/editor/articles/ftest.html", "Clicked URL Matches with URL of the New Window"); |
||
| 55 | }); |
||
| 56 | |||
| 57 | it('The updated single article is found in the manager', function(client) { |
||
| 58 | client |
||
| 59 | .useXpath() |
||
| 60 | .url('http://localhost:3003/abe/editor') |
||
| 61 | .waitForElementVisible('//body') |
||
| 62 | .pause(1000) |
||
| 63 | .assert.containsText("//table[@id='navigation-list']/tbody/tr[1]/td[2]/a", "/articles/ftest.html"); |
||
| 64 | }); |
||
| 65 | |||
| 66 | it('The updated single article is edited once more with a new name', function(client) { |
||
| 67 | client |
||
| 68 | .useXpath() |
||
| 69 | .url('http://localhost:3003/abe/editor/articles/ftest.html#slug') |
||
| 70 | .waitForElementVisible('//body') |
||
| 71 | .assert.title('Abe') |
||
| 72 | .setValue("//div[@data-precontrib-templates='single']//input[@id='name']", 'updated') |
||
| 73 | .click("//button[@class='btn btn-primary'][2]") |
||
| 74 | .pause(2000) |
||
| 75 | .assert.urlEquals("http://localhost:3003/abe/editor/articles/ftestupdated.html", "Clicked URL Matches with URL of the New Window"); |
||
| 76 | }); |
||
| 77 | |||
| 78 | it('The updated single article is found in the manager', function(client) { |
||
| 79 | client |
||
| 80 | .useXpath() |
||
| 81 | .url('http://localhost:3003/abe/editor') |
||
| 82 | .waitForElementVisible('//body') |
||
| 83 | .pause(1000) |
||
| 84 | .assert.containsText("//table[@id='navigation-list']/tbody/tr[1]/td[2]/a", "/articles/ftestupdated.html"); |
||
| 85 | }); |
||
| 86 | |||
| 87 | it('The updated single article is duplicated', function(client) { |
||
| 88 | client |
||
| 89 | .useXpath() |
||
| 90 | .url('http://localhost:3003/abe/editor/articles/ftestupdated.html#slug') |
||
| 91 | .waitForElementVisible('//body') |
||
| 92 | .assert.title('Abe') |
||
| 93 | .clearValue("//div[@data-precontrib-templates='single']//input[@id='name']") |
||
| 94 | .setValue("//div[@data-precontrib-templates='single']//input[@id='name']", 'ftest') |
||
| 95 | .click("//button[@class='btn btn-primary'][1]") |
||
| 96 | .pause(2000) |
||
| 97 | .assert.urlEquals("http://localhost:3003/abe/editor/articles/ftest.html", "Clicked URL Matches with URL of the New Window"); |
||
| 98 | }); |
||
| 99 | |||
| 100 | it('The updated single article + duplicated are found in the manager', function(client) { |
||
| 101 | client |
||
| 102 | .useXpath() |
||
| 103 | .url('http://localhost:3003/abe/editor') |
||
| 104 | .waitForElementVisible('//body') |
||
| 105 | .pause(1000) |
||
| 106 | .assert.containsText("//table[@id='navigation-list']/tbody/tr[1]/td[2]/a", "/articles/ftest.html") |
||
| 107 | .assert.containsText("//table[@id='navigation-list']/tbody/tr[2]/td[2]/a", "/articles/ftestupdated.html"); |
||
| 108 | }); |
||
| 109 | |||
| 110 | it('The updated article is deleted in the manager', function(client) { |
||
| 111 | client |
||
| 112 | .useXpath() |
||
| 113 | .url('http://localhost:3003/abe/editor') |
||
| 114 | .waitForElementVisible('//body') |
||
| 115 | .pause(1000) |
||
| 116 | .click("//table[@id='navigation-list']/tbody/tr[2]/td[7]/div/a[last()]") |
||
| 117 | .pause(1000) |
||
| 118 | .acceptAlert() |
||
| 119 | .url('http://localhost:3003/abe/editor') |
||
| 120 | .pause(2000) |
||
| 121 | .expect.element("//table[@id='navigation-list']/tbody/tr[2]/td[2]/a").text.to.not.contain('/articles/ftestupdated.html'); |
||
| 122 | }); |
||
| 123 | |||
| 124 | it('The updated single article is published', function(client) { |
||
| 125 | client |
||
| 126 | .useXpath() |
||
| 127 | .url('http://localhost:3003/abe/editor/articles/ftest.html#slug') |
||
| 128 | .waitForElementVisible('//body') |
||
| 129 | .assert.title('Abe') |
||
| 130 | .click("//div[@class='btns']/button[3]") |
||
| 131 | .pause(2000) |
||
| 132 | .assert.containsText("//div[@class='display-status']/span", "publish") |
||
| 133 | .url('http://localhost:3003/abe/editor') |
||
| 134 | .waitForElementVisible('//body') |
||
| 135 | .assert.containsText("//table[@id='navigation-list']/tbody/tr[1]/td[6]/a[@class='checkmark label-published']", "✔"); |
||
| 136 | }); |
||
| 137 | |||
| 138 | it('The updated article is unpublished in the manager', function(client) { |
||
| 139 | client |
||
| 140 | .useXpath() |
||
| 141 | .url('http://localhost:3003/abe/editor') |
||
| 142 | .waitForElementVisible('//body') |
||
| 143 | .pause(1000) |
||
| 144 | .click("//table[@id='navigation-list']/tbody/tr[1]/td[7]/div/a") |
||
| 145 | .pause(1000) |
||
| 146 | .acceptAlert() |
||
| 147 | .url('http://localhost:3003/abe/editor') |
||
| 148 | .pause(2000) |
||
| 149 | .assert.cssClassPresent("//table[@id='navigation-list']/tbody/tr[1]/td[5]/a", "label-draft"); |
||
| 150 | }); |
||
| 151 | |||
| 152 | it('The updated article is deleted in the manager', function(client) { |
||
| 153 | client |
||
| 154 | .useXpath() |
||
| 155 | .url('http://localhost:3003/abe/editor') |
||
| 156 | .waitForElementVisible('//body') |
||
| 157 | .pause(1000) |
||
| 158 | .click("//table[@id='navigation-list']/tbody/tr[1]/td[7]/div/a") |
||
| 159 | .pause(1000) |
||
| 160 | .acceptAlert() |
||
| 161 | .url('http://localhost:3003/abe/editor') |
||
| 162 | .pause(2000) |
||
| 163 | .expect.element("//table[@id='navigation-list']/tbody/tr[1]/td[2]/a").text.to.not.contain('/articles/ftest.html'); |
||
| 164 | }); |
||
| 165 | }); |
||
| 166 | }); |